#!/bin/bash
#手动启停upush应用

#jar包路径，带后缀
#/usr/local/winit_upush2/upush-office/upush2-push-office.jar


pakcagepath=$2

export JAVA_HOME=/usr/java/jdk1.8.0_141
export PATH=$PATH:${javaHome}/bin


function start(){
    nohup $1 </dev/null >/dev/null 2>&1 &
}
function stop(){
    ps -ef | grep -w "$1" | grep -v 'grep' |grep -v 'tail' | grep -v 'ssh' | grep -v 'springboot.sh' |awk '{print $2}'| xargs kill -9
    sleep 3
    ps -ef | grep -w "$1" | grep -v 'grep' |grep -v 'tail' | grep -v 'springboot.sh' | grep -v 'ssh' 
}
function restart(){
	echo "stop $1"
    stop $1
    echo "stop end $1"
    sleep 5
    echo "start $1"
    start $1
    echo "start end $1"
}

case "$1" in
    start)
        start $pakcagepath ;;
    stop)
        stop $pakcagepath ;;
    restart)
        restart $pakcagepath ;;
    *)
    	echo "Usage: springboot.sh {start|stop|restart} ${pakcagepath}"
    exit 1
esac